"""
示例插件A - 文本处理插件
"""

class TextProcessorPlugin:
    """文本处理插件类"""
    
    def __init__(self):
        self.name = "TextProcessor"
        self.version = "1.0.0"
    
    def process_text(self, text, operation="upper"):
        """
        处理文本
        
        Args:
            text: 输入文本
            operation: 操作类型 ('upper', 'lower', 'reverse', 'capitalize')
        
        Returns:
            处理后的文本
        """
        if operation == "upper":
            return text.upper()
        elif operation == "lower":
            return text.lower()
        elif operation == "reverse":
            return text[::-1]
        elif operation == "capitalize":
            return text.capitalize()
        else:
            return text
    
    def word_count(self, text):
        """统计单词数量"""
        return len(text.split())
    
    def get_info(self):
        """获取插件信息"""
        return {
            "name": self.name,
            "version": self.version,
            "description": "文本处理插件，提供各种文本操作功能"
        }

# 插件实例
plugin_instance = TextProcessorPlugin()

def register(plugin_manager):
    """注册插件到插件管理器"""
    plugin_manager.register_plugin('plugin_a', plugin_instance)
    print(f"文本处理插件已注册: {plugin_instance.name} v{plugin_instance.version}") 